<?php
/**
 * Created by PhpStorm.
 * User: lidan
 * Date: 2018/10/8
 * Time: 下午12:19
 */

namespace Imooc;


use Imooc\Database\MySQLi;

class User
{
    public $id;
    public $name;
    public $mobile;
    public $regtime;

    protected $db;
    function __construct($id)
    {
        $this->db = new MySQLi();//此处可以替换成MySQLi()或PDO(),下面的接口方法和参数都不会变，适配器实现
        $this->db->connect('127.0.0.1','root','','test');
        $res = $this->db->query('select * from user limit 1');
        $data = $res->fetch_assoc();

    }


    function __destruct()
    {
        $this->db->close();
    }
}